package com.example.springbott.controller;

import com.example.springbott.aspactJ.OperationName;
import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketIssue;
import com.example.springbott.bean.common.CommonData;
import com.example.springbott.service.AdminIssueService;
import com.example.springbott.vo.IssueVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 付常莹
 * @description: TODO
 * @date 2022/11/21 19:22
 * <p>
 * 该Controller用于通用问题模块
 */
@RestController
@RequestMapping("admin/issue")
public class IssueController {
    @Resource
    AdminIssueService adminIssueService;


    /**
     * 该方法用于通用问题模块的查找接口
     *
     * @param page
     * @param limit
     * @param question
     * @param sort
     * @param order
     * @return
     */
    @RequiresPermissions("admin:issue:list")
    @GetMapping("list")
    @OperationName("1")
    public BaseRespVo list(Integer page, Integer limit, String question, String sort, String order) {
        CommonData<MarketIssue> data = adminIssueService.list(page, limit, question, sort, order);
        return BaseRespVo.ok(data);
    }


    /**
     * 该方法用于添加通用问题接口
     *
     * @param marketIssue
     * @return
     */
    @RequiresPermissions("admin:issue:create")
    @PostMapping("create")
    @OperationName("1")
    public BaseRespVo create(@RequestBody MarketIssue marketIssue) {
        MarketIssue data = adminIssueService.create(marketIssue);
        return BaseRespVo.ok(data);
    }


    /**
     * 该方法用于修改，编辑通用问题接口
     *
     * @param marketIssue
     * @return
     */
    @RequiresPermissions("admin:issue:update")
    @PostMapping("update")
    @OperationName("1")
    public BaseRespVo update(@RequestBody MarketIssue marketIssue) {
        MarketIssue data = adminIssueService.update(marketIssue);
        return BaseRespVo.ok(data);
    }

    /**
     * 该方法用于删除通用问题接口
     * @param marketIssue
     * @return
     */
    @RequiresPermissions("admin:issue:delete")
    @PostMapping("delete")
    @OperationName("1")
    public BaseRespVo delete(@RequestBody MarketIssue marketIssue) {
        adminIssueService.delete(marketIssue);
        return BaseRespVo.ok(null);
    }
}
